<?php
namespace Admin\Controller;

use Common\Controller\AdminbaseController;
class LiuyanController extends AdminbaseController{
	

	
	function _initialize() {
		parent::_initialize();
		$this->db = D("Liuyan");

	}
	
	function index(){
		




		$count=$this->db->count();
		$page = $this->page($count);
		$list=$this->db->limit($page->firstRow . ',' . $page->listRows)->order ( "id desc")->select();
		
		$this->assign("Page",$page->show(""));
		
		$this->assign("list",$list);
		
		$this->display();
	}
	

	
	
	function huida(){

		if(IS_POST){

			if ($this->db->create($_POST)) {

				if ($this->db->save()!==false) {


					$this->success("回答成功！");
				} else {
					$this->error("回答失败！");
				}
			} else {
				$this->error($this->db->getError());
			}
		}else{


			$data=$this->db->where(array("id"=>I('get.id')))->find();
			$this->assign("data",$data);

			$this->display();
		}
		}

	
	function edit(){
		
		
		if(IS_POST){
			if ($this->db->create($_POST)) {
				
				if ($this->db->save()!==false) {


					$this->success("保存成功！");
				} else {
					$this->error("保存失败！");
				}
			} else {
				$this->error($this->db->getError());
			}
		
		}else{
	
		$id= intval(I("get.id"));
		if(!$id){
			$this->error("缺少参数！");
		}

		$r=$this->db->where("id=$id")->find();
		$this->assign("edit",true);
		$this->assign("data",$r);
		$this->display("form");
		}
	}


	function  code(){



		$this->display();



	}


	function  log(){


		$id= I("get.id");



		$map["code_id"]=$id;

		$count=$this->log->where($map)->count();
		$page = $this->page($count);
		$list=$this->log->limit($page->firstRow . ',' . $page->listRows)->order ( "id desc")->where($map)->select();

		$this->assign("Page",$page->show(""));

		$this->assign("list",$list);

		$this->display();





}
	

	
	
	}